package com.ruoyi.yljf.controller.AppController;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.security.annotation.Anonymous;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.yljf.domain.Active;
import com.ruoyi.yljf.domain.ActiveOther;
import com.ruoyi.yljf.domain.dto.ActiveDTO;
import com.ruoyi.yljf.domain.enums.yljfEnums;
import com.ruoyi.yljf.domain.vo.ActiveArticleVO;
import com.ruoyi.yljf.domain.vo.ActiveVO;
import com.ruoyi.yljf.service.IActiveOtherService;
import com.ruoyi.yljf.service.IActiveService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 活动Controller
 * 对应
 * @author metaee
 * @date 2025-02-13
 */
@Anonymous
@RestController
@RequestMapping("api/active")
public class ApiActiveController extends BaseController {
    @Autowired
    private IActiveService activeService;
    @Autowired
    private IActiveOtherService activeOtherService;

    /**
     * 查询活动列表
     */
    @GetMapping("/page")
    public TableDataInfo page(ActiveDTO activeDTO,
                              @RequestHeader(value = "Authorization", required = false) String authorization) {
        Active active = new Active(activeDTO);
        startPage();
        Long userId = null;
        if (StringUtils.isNotEmpty(authorization)) {
            userId = getUserId();
        }
        List<Active> list = activeService.selectActiveList(active);
        List<ActiveVO> listVO = activeService.queryActiveList(list,userId);
        return getDataTableInfo(listVO,list);
    }

    /**
     * 获取活动详细信息
     */
    @GetMapping(value = "/{activeId}")
    public AjaxResult getInfo(@PathVariable("activeId") Long activeId) {
        ActiveVO activeVO = activeService.queryById(activeId);
        return success(activeVO);
    }




}

